package com.juku2024.juku.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.model.PlayInfoResponse
import com.juku2024.juku.tools.AppUtils

class QualityAdapter(videoUrls: ArrayList<PlayInfoResponse>?) :
    BaseQuickAdapter<PlayInfoResponse, BaseViewHolder>(R.layout.dl_item_quailty, videoUrls) {

    override fun convert(holder: BaseViewHolder, item: PlayInfoResponse) {
        // 推荐图标
        holder.setVisible(R.id.iv_source_recommend, item.isRecommend)

        // 文本颜色
        val color = if (item.isSelected){
            R.color.color_text_light
        } else {
            R.color.app_text_white
        }
        // 设置线路名称和集数
        holder.setText(R.id.tvQuality, AppUtils.getSourceName(item.id) + "   (共${item.episodes.size}集)")
            .setTextColorRes(R.id.tvQuality, color)
    }

}